#!/bin/sh
user="123456789"
passwd="123456"
dir="/root/login"
url="http://172.16.245.50/include/auth_action.php"

login(){
#get ip
ip=`ifconfig | grep 'inet addr'| grep -vE '(192|127)' | awk '{print $2}' | awk -F ':' '{print $ 2}'`
#echo $ip
#system log
logger "edu login:" "ip: $ip ,user: $user, password: $passwd, login now"

#login
wget -qP $dir --post-data="action=login&username=$user@yd&password=$passwd&ac_id=2&user_ip=$ip&nas_ip=&user_mac=&save_me=1&ajax=1" $url
}

while sleep 10
do
	login
	res=`cat $dir/auth_action.php | awk -F ',' '{print $1}'`
	rm -f $dir/auth_action.php
	if [ "$res" == "login_ok" ]; then
		logger "[edu status]" "online"
		#echo $res
	else
		/root/login.sh
	fi
done
